package com.common.project.util.oss;

/**
 * @ClassName OssConfig
 * @Description
 * @Author jiangshicun@bicai365.com
 * @Date 2019/6/20 14:25
 */
public class OssConfig {
    public static final String endpoint = "oss-cn-beijing.aliyuncs.com";
    public static final String internet = "oss-cn-beijing.aliyuncs.com";
    public static final String accessKeyId = "LTAIxGyQiezyEI94";
    public static final String accessKeySecret = "H94alhsC9SmTnyIkwLSFeatNHIZZ8l";
    public static final String bucketNameTest = "bicai-architecture-test";
    public static final String bucketNameRelease = "bicai-architecture";

    public OssConfig() {
    }

    public static String getAccessUrl(boolean isInternet, String profile) {
        return getAccessUrl(getBucketName(profile), isInternet);
    }

    public static String getBucketName(String profile) throws NullPointerException {
        if (profile != null && !"".equals(profile)) {
            return "release".equals(profile) ? "bicai-architecture" : "bicai-architecture-test";
        } else {
            throw new NullPointerException("profile can not be null or empty");
        }
    }

    public static String getAccessUrl(String bucketName, boolean isInternet) {
        return String.format("https://%s.%s", bucketName, isInternet ? internet : endpoint);
    }
}
